package com.zzyl.nursing.controller.member;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zzyl.common.utils.UserThreadLocal;
import com.zzyl.nursing.dto.BindFamilyDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.impl.FamilyMemberServiceImpl;
import com.zzyl.nursing.vo.BindElderVo;
import com.zzyl.nursing.vo.LoginVo;
import com.zzyl.nursing.vo.MemberElderVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zzyl.common.annotation.Log;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.enums.BusinessType;
import com.zzyl.nursing.domain.FamilyMember;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.common.utils.poi.ExcelUtil;
import com.zzyl.common.core.page.TableDataInfo;

/**
 * 老人家属Controller
 * 
 * @author ruoyi
 * @date 2025-08-26
 */
@RestController
@RequestMapping("/member/user")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;

    @PostMapping("/login")
    public AjaxResult login(@RequestBody UserLoginRequestDto userLoginRequestDto){
        LoginVo loginVo = familyMemberService.login(userLoginRequestDto);
        return success(loginVo);

    }
    /**
     * 绑定老人家属
     */

    @PostMapping("/add")
    public AjaxResult add(@RequestBody BindFamilyDto bindFamilyDto){
        familyMemberService.add(bindFamilyDto);
        return success();
    }

    /**
     * 查看家人列表
     */
    @GetMapping("/my")
    public AjaxResult my(){
        List<BindElderVo> bindElderVo = familyMemberService.myBindElder();
        return success(bindElderVo);

    }
    /**
     * 查看家人列表（分页查询）
     */
    @GetMapping("/list-by-page")
    public AjaxResult listByPage(){
        List<MemberElderVo> memberElderVo = familyMemberService.listByPage();
        return success(memberElderVo);
    }

    /**
     * 解绑信息(根据id删除数据库绑定的信息)
     */
    @DeleteMapping("/deleteById")
    public AjaxResult deleteById(Long id){
        familyMemberService.deleteFamilyMemberElderById(id);
        return success();
    }




}
